//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:21:18 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace Utility

{
		
		#region Namespace Import Declarations
		
			using System;
			using System.Security.Cryptography;
			using System.Text;
			
		#endregion
		
	public class Class1
	
	{
		
		#region Fields
			private SymmetricAlgorithm mCryptoService;
			private ICryptoTransform mDecryptor;
			private ICryptoTransform mEncryptor;
		#endregion
		
		#region Constructors
		
			public Class1 ()
			
			{
				this.mCryptoService = ((SymmetricAlgorithm) null);
				this.mEncryptor = ((ICryptoTransform) null);
				this.mDecryptor = ((ICryptoTransform) null);
				return;
			}
			
		#endregion
		
		#region Methods
		
			public string Decrypt (string s)
			
			{
				byte[] theByteArray;
				string theString;
				byte[] theByteArray2;
				string theString2;
				this.mCryptoService = ((SymmetricAlgorithm) new DESCryptoServiceProvider ());
				theByteArray = this.GetLegalKey ("CryptoLib");
				this.mCryptoService.Key = theByteArray;
				this.mCryptoService.Mode = CipherMode.ECB;
				this.mDecryptor = this.mCryptoService.CreateDecryptor ();
				
			L_004B:
				
				{
				}
				
			L_0046:
				
				{
				}
				theString = ((s == null) ? string.Empty : s);
				if (theString.Length <= 0)
				{
					goto L_0079;
				}
				theByteArray2 = Convert.FromBase64String (theString);
				theString2 = Encoding.UTF8.GetString (this.mDecryptor.TransformFinalBlock (theByteArray2, 0, theByteArray2.Length));
				goto L_007D;
				
			L_0079:
				
				{
				}
				theString2 = theString;
				goto L_007D;
				
			L_007D:
				
				{
				}
				return theString2;
			}
			
			public string Encrypt (string s)
			
			{
				byte[] theByteArray;
				string theString;
				byte[] theByteArray2;
				string theString2;
				this.mCryptoService = ((SymmetricAlgorithm) new DESCryptoServiceProvider ());
				theByteArray = this.GetLegalKey ("CryptoLib");
				this.mCryptoService.Key = theByteArray;
				this.mCryptoService.Mode = CipherMode.ECB;
				this.mEncryptor = this.mCryptoService.CreateEncryptor ();
				
			L_004B:
				
				{
				}
				
			L_0046:
				
				{
				}
				theString = ((s == null) ? string.Empty : s);
				if (theString.Length <= 0)
				{
					goto L_0079;
				}
				theByteArray2 = Encoding.UTF8.GetBytes (theString);
				theString2 = Convert.ToBase64String (this.mEncryptor.TransformFinalBlock (theByteArray2, 0, theByteArray2.Length));
				goto L_007D;
				
			L_0079:
				
				{
				}
				theString2 = theString;
				goto L_007D;
				
			L_007D:
				
				{
				}
				return theString2;
			}
			
			private byte[] GetLegalKey (string Key)
			
			{
				string theString;
				int i;
				byte[] theByteArray;
				theString = Key;
				if (this.mCryptoService.LegalKeySizes.Length <= 0)
				{
					goto L_00BD;
				}
				i = this.mCryptoService.LegalKeySizes[0].MinSize;
				if ((theString.Length * 8) <= this.mCryptoService.LegalKeySizes[0].MaxSize)
				{
					goto L_0062;
				}
				theString = theString.Substring (0, ((int) (this.mCryptoService.LegalKeySizes[0].MaxSize / 8)));
				goto L_00BD;
				
			L_0062:
				
				{
				}
				if ((theString.Length * 8) >= i)
				{
					goto L_00BD;
				}
				if (this.mCryptoService.LegalKeySizes[0].SkipSize != 0)
				{
					goto L_008F;
				}
				theString = theString.PadRight (((int) (i / 8)), '\u0020');
				goto L_00BD;
				
			L_008F:
				
				{
				}
				goto L_00A6;
				
			L_0091:
				
				{
				}
				i += this.mCryptoService.LegalKeySizes[0].SkipSize;
				
			L_00A6:
				
				{
				}
				if ((theString.Length * 8) > i)
				{
					goto L_0091;
				}
				theString = theString.PadRight (((int) (i / 8)), '\u0020');
				
			L_00BD:
				
				{
				}
				theByteArray = Encoding.ASCII.GetBytes (theString);
				goto L_00CB;
				
			L_00CB:
				
				{
				}
				return theByteArray;
			}
			
		#endregion
	}
	
}

